package com.zerosky.crm.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.zerosky.crm.po.Employee;
import com.zerosky.crm.util.BaseAction;

@Controller
@RequestMapping(value = "wap")
public class phoneController extends BaseAction {

	/**
	 * 登录
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/login.do")
	@ResponseBody
	public ModelAndView login(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/login/login");
		return m;
	}

	/**
	 * 首页
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/index.do")
	@ResponseBody
	public ModelAndView index(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/index");
		return m;
	}

	/**
	 * 工作
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/body.do")
	@ResponseBody
	public ModelAndView body(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/body");
		return m;
	}

	/**
	 * 合同
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/contract.do")
	@ResponseBody
	public ModelAndView contract(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/contract");
		return m;
	}

	/**
	 * 客户
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/client.do")
	@ResponseBody
	public ModelAndView client(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		return new ModelAndView("WEB-INF/wap/client");
	}

	/**
	 * 个人中心
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/my.do")
	@ResponseBody
	public ModelAndView my(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/my");
		return m;
	}

	/**
	 * 通知
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_notice.do")
	@ResponseBody
	public ModelAndView frame_notice(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_notice");
		return m;
	}

	/**
	 * 汇报
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_weekly.do")
	@ResponseBody
	public ModelAndView frame_weekly(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_weekly");
		return m;
	}

	/**
	 * 打卡
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_clock.do")
	@ResponseBody
	public ModelAndView frame_clock(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_clock");
		return m;
	}

	/**
	 * 销售图表
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_chart.do")
	@ResponseBody
	public ModelAndView frame_chart(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_chart");
		return m;
	}

	/**
	 * 产品
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_product.do")
	@ResponseBody
	public ModelAndView frame_product(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_product");
		return m;
	}

	/**
	 * 我的员工
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_record.do")
	@ResponseBody
	public ModelAndView frame_record(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_employee");
		return m;
	}

	/**
	 * 机会
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_chance.do")
	@ResponseBody
	public ModelAndView frame_chance(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_chance");
		return m;
	}

	/**
	 * 市场活动
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_market.do")
	@ResponseBody
	public ModelAndView frame_market(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_market");
		return m;
	}

	/**
	 * 员工通讯录
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_phonebook.do")
	@ResponseBody
	public ModelAndView frame_phonebook(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_phonebook");
		return m;
	}

	/**
	 * 行程
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_plan.do")
	@ResponseBody
	public ModelAndView frame_plan(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_plan");
		return m;
	}

	/**
	 * 公海池
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_gonghaichi.do")
	@ResponseBody
	public ModelAndView frame_gonghaichi(HttpServletRequest request, HttpSession session,
			HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_gonghaichi");
		return m;
	}

	/**
	 * 我的名片
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_card.do")
	@ResponseBody
	public ModelAndView frame_card(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_card");
		return m;
	}

	/**
	 * 查看机会
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_chance_detailed.do")
	@ResponseBody
	public ModelAndView frame_chance_detailed(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_chance_detailed");
		m.addObject("id", id);
		return m;
	}

	/**
	 * 通知详细
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_notice_detailed.do")
	@ResponseBody
	public ModelAndView frame_notice_detailed(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_notice_detailed");
		m.addObject("id", id);
		return m;
	}

	/**
	 * 汇报详细
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_weekly_detailed.do")
	@ResponseBody
	public ModelAndView frame_weekly_detailed(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_weekly_detailed");
		m.addObject("id", id);
		return m;
	}

	/**
	 * 签到详细
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_clock_detailed.do")
	@ResponseBody
	public ModelAndView frame_clock_detailed(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_clock_detailed");
		m.addObject("id", id);
		return m;
	}

	/**
	 * 客户详细
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_client_detailed.do")
	@ResponseBody
	public ModelAndView frame_client_detailed(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_client_detailed");
		m.addObject("id", id);
		return m;
	}

	/**
	 * 客户功能共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_client.do")
	@ResponseBody
	public ModelAndView publics(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/client/" + path);
		return m;
	}

	/**
	 * 工作功能共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_work.do")
	@ResponseBody
	public ModelAndView public_work(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/work/" + path);
		return m;
	}

	/**
	 * 销售功能共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_chart.do")
	@ResponseBody
	public ModelAndView public_chart(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/chart/" + path);
		return m;
	}

	/**
	 * 用户功能共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_users.do")
	@ResponseBody
	public ModelAndView public_users(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path,String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/users/" + path);
		m.addObject("id",id);
		return m;
	}
	
	
	/**
	 * 客户功能共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_customer.do")
	@ResponseBody
	public ModelAndView public_customer(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path,String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/customer/" + path);
		m.addObject("id",id);
		return m;
	}
	

	/**
	 * 员工通讯录共用跳转
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/public_phonebook.do")
	@ResponseBody
	public ModelAndView public_phonebook(HttpServletRequest request, HttpSession session, HttpServletResponse response,
			String path) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/phonebook/" + path);
		return m;
	}

	/**
	 * 客户
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/menu.do")
	@ResponseBody
	public Map<String, Object> menu(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		Map<String, Object> json = new HashMap<String, Object>(); // 定义返回map集合
		try {
			Employee user = (Employee) session.getAttribute("loginUser");
			boolean isStart = false;
			if (!user.getQuarters().equals("0")) {//验证经理权限
				isStart = true;
				json.put("flag", 1);
			}
			if (isStart) {
				json.put("isStart", isStart);
			}
		} catch (Exception e) {
			json.put("flag", -1);
		}
		return json;
	}
	
	
	/**
	 * 新闻分享页面
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/news_detailed_body.do")
	@ResponseBody
	public ModelAndView news_detailed_body(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/news/news_detailed_body");
		m.addObject("id", id);
		return m;
	}
	
	/**
	 * 活动分享页面
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/market_detailed_body.do")
	@ResponseBody
	public ModelAndView market_detailed_body(HttpServletRequest request, HttpSession session,
			HttpServletResponse response, String id,String empid) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/market/market_detailed_body");
		m.addObject("id", id);
		m.addObject("empid", id);
		return m;
	}
	
	
	
	/**
	 * 客户-我的中心
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_myCustomer.do")
	@ResponseBody
	public ModelAndView frame_myCustomer(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_myCustomer");
		return m;
	}
	
	/**
	 * 客户-服务支持列表2
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_serviceSupport.do")
	@ResponseBody
	public ModelAndView frame_serviceSupport(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_serviceSupport");
		return m;
	}
	
	
	/**
	 * 新闻资讯0
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/frame_news.do")
	@ResponseBody
	public ModelAndView frame_news(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/frame_news");
		return m;
	}
	
	/**
	 * 客户主页
	 * 
	 * @throws Exception
	 */
	@RequestMapping("/mainCustomer.do")
	@ResponseBody
	public ModelAndView mainCustomer(HttpServletRequest request, HttpSession session, HttpServletResponse response) {
		ModelAndView m = new ModelAndView("WEB-INF/wap/mainCustomer");
		return m;
	}
	
}
